Edit and Continue

Edit and Continue enables you to change your source code and apply those changes (with some limitations) while your program is running under the Visual Studio debugger (or in break mode). Not only does this save time, it also gives you the chance to see the effect of changes during the current conditions under which your program is running. When you install Visual Studio, Edit and Continue is turned on by default. You can turn it off if you prefer.

To enable/disable Edit and Continue

  1. From the Tools Menu, click Options.
  2. In the Options dialog box, select the Debugging folder.
  3. In the Edit and Continue group, select or clear the Enable Edit and Continue check box.
  4. Click OK.

When you edit code during you are debugging, Edit and Continue can apply the changes:

When you apply code changes explicitly, Edit and Continue updates the compiled code you are debugging, but does not step or resume execution.

If you prefer, you can disable the automatic invocation of Edit and Continue by Go and Step commands. You might do this if you are making edits to the code that you do not want applied during the current debugging session.

To enable/disable automatic invocation of Edit and Continue

  1. From the Tools Menu, click Options.
  2. In the Options dialog box, select the Debugging folder.
  3. In the Edit and Continue group, select or clear the Invoked by debug commands check box.

    Note   You also have the option of having the debugger ask you before applying code changes prior to a debug command. If you want to be asked, select the Ask me first check box.

  4. Click OK.

Because Invoked by debug commands is a tools option, altering this setting affects all projects you work on. You do not need to rebuild your application after changing this setting. You can change the setting even while debugging. If you build your application from the command line or from a makefile but debug in the Visual C++ environment, you can still use Edit and Continue if you set the /ZI option.

Caution   Do not enable Edit and Continue (/ZI) if you are debugging optimized code. Edit and Continue is incompatible with compiler optimizations. The result is a compiler error.

Some code changes cause the point of execution to move to a new location when Edit and Continue applies the changes. Edit and Continue places the point of execution as accurately as possible, but the results may not be correct in all cases. A dialog box informs you when the point of execution changes. You should verify that the location is correct before you continue debugging. If it is not correct, use the Set Next Statement, as described in Setting the Execution Point.